package com.pgy.general.result;

/**
 * @Auther:superChao
 * @Date: 2021/01/13/19:41
 * @Version:2.0.0
 */
public class RetResponse {


    private final static String SUCCESS = "操作成功！";
    private final static String FAIL= "操作失败！";
    //1,返回操作成功
    public static  RetResult makeOKRsp() {
        return new RetResult().setCode(RetCode.SUCCESS).setMsg(SUCCESS);
    }
    //2,操作成功并返回数据
    public static  RetResult makeOKRsp(Object data) {
        return new RetResult().setCode(RetCode.SUCCESS).setMsg(SUCCESS).setData(data);
    }
    public static  RetResult makeOKRsp(RetCode code, Object data, String msg) {
        return new RetResult().setCode(code).setMsg(msg).setData(data);
    }
    //3,返回“查询无结果”
    public static  RetResult makeErrRsp() {
        return new RetResult().setCode(RetCode.FAIL).setMsg(FAIL);
    }
    //4,操作失败返回自定义信息
    public static  RetResult makeErrRsp(String message) {
        return new RetResult().setCode(RetCode.FAIL).setMsg(message);
    }
    //5,服务器异常
    public static  RetResult serverErrRsp(String msg) {
        return new RetResult().setCode(RetCode.INTERNAL_SERVER_ERROR).setMsg(msg);
    }
    //6,自定义状态码和返回信息
    public static  RetResult makeRsp(RetCode code, String msg) {
        return new RetResult().setCode(code).setMsg(msg);
    }
    //7,自定义状态码返回信息和数据
    public static  RetResult makeRsp(RetCode code, String msg, Object data) {
        return new RetResult().setCode(code).setMsg(msg).setData(data);
    }


}
